package shiro.com.controller.file;

import java.util.List;
import java.util.Map;

import com.sun.org.apache.regexp.internal.RE;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import shiro.com.basie.controller.BaseController;
import shiro.com.basie.domain.AjaxResult;
import shiro.com.domain.TableDataInfo;
import shiro.com.domain.file.FileUp;
import shiro.com.domain.file.vo.FileUpVo;
import shiro.com.service.file.IFileUpService;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2022-12-12
 */
@RestController
@RequestMapping("/up/up")
public class FileUpController extends BaseController
{
    @Autowired
    private IFileUpService fileUpService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FileUp fileUp)
    {
        List<FileUp> list = fileUpService.selectFileUpList(fileUp);
        return getDataTable(list);
    }
    @GetMapping("/mothe")
    public AjaxResult getMoth(FileUp fileUp)
    {
        Map<String, List<String>> list = fileUpService.selectFileUpGetMothList(fileUp);
        return  AjaxResult.success(list);
    }

    @PostMapping("/phone")
     public TableDataInfo phonebyName(@Param("phone") String phone){
        List<FileUpVo> fileUpVos = fileUpService.selectNameByPhone(phone);
        return getDataTable(fileUpVos);
    }

//    /**
//     * 导出【请填写功能名称】列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:up:export')")
//    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
//    @GetMapping("/export")
//    public AjaxResult export(FileUp fileUp)
//    {
//        List<FileUp> list = fileUpService.selectFileUpList(fileUp);
//        ExcelUtil<FileUp> util = new ExcelUtil<FileUp>(FileUp.class);
//        return util.exportExcel(list, "【请填写功能名称】数据");
//    }
//
//    /**
//     * 获取【请填写功能名称】详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('system:up:query')")
    @GetMapping(value = "/{fileUpId}")
    public AjaxResult getInfo(@PathVariable("fileUpId") Long fileUpId)
    {
        return AjaxResult.success(fileUpService.selectFileUpById(fileUpId));
    }

    @GetMapping(value = "delete/{fileUpId}")
    public AjaxResult remove2(@PathVariable("fileUpId") Long fileUpId)
    {
        return AjaxResult.success(fileUpService.deleteFileUpByIds2(fileUpId));
    }
//
//    /**
//     * 新增【请填写功能名称】
//     */
//    @PreAuthorize("@ss.hasPermi('system:up:add')")
//    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add( FileUp fileUp)
    {

        return toAjax(fileUpService.insertFileUp(fileUp)).put("fileUpId",fileUp.getFileUpId());
    }


//
//    /**
//     * 修改【请填写功能名R称】
//     */
//    @PreAuthorize("@ss.hasPermi('system:up:edit')")
//    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(FileUp fileUp)
    {
        return toAjax(fileUpService.updateFileUp(fileUp));
    }
//
//    /**
//     * 删除【请填写功能名称】
//     */
//    @PreAuthorize("@ss.hasPermi('system:up:remove')")
//    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fileUpIds}")
    public AjaxResult remove(@PathVariable Long[] fileUpIds)
    {
        return toAjax(fileUpService.deleteFileUpByIds(fileUpIds));
    }



}
